import pymysql

con = pymysql.connect(host="localhost",user="root",password="123456",database="spider")
# 获取游标
cursor = con.cursor()
# 查询语句
sql = "select * from users where name='' or 1=1"
# 执行
cursor.execute(sql)
# 取回执行结果
data = cursor.fetchall()
print(data)
# 可以占位符的方式查询
sql1 = "select * from users where name=%s"
# 执行
cursor.execute(sql1,"张三")
# 取回结果
data = cursor.fetchall()
print(data)